# Creating a set
# 集合不会有重复的元素
# things = set(['table', 'chair', 'door', 'chair', 'chair'])
# print(things)
# print(type(things))
#
# # 判断table在不在这个集合中
# if 'table' in things:
#     print("has table")
#
# # 第二种
# other = {'table', 'chair', 'door', 'chair', }
# print(type(other))
# print(other)

# Creating an empty set
# objects = set()
# # objects = {}  # 用来创建空字典
# print(objects)
# print(type(objects))

# Adding an element to a set (add)
# objects = set()  # 空集合
# print(objects)
#
# objects.add('Mars')  # 加了一个mars
# print(objects)
#
# objects.add('Mars')
# print(objects)
#
# objects.add('Neptun')
# print(objects)

# Merging one set into another set (update)
# objects = set(['Mars', 'Jupiter', 'Saturn'])
# internal = set(['Mercury', 'Venus', 'Earth', 'Mars'])
#
# objects.update(internal)  # object 合并了internal这个集合
# print(objects)
# print(internal)


# objects = set(['Mars', 'Jupiter', 'Saturn'])
# internal = set(['Mercury', 'Venus', 'Earth', 'Mars'])
# internal.update(objects)
# print(objects)
# print(internal)

# set intersection
#
# english = set(['door', 'car', 'lunar', 'era'])
# spanish = set(['era', 'lunar', 'hola'])
#
# print('english: ', english)
# print('spanish: ', spanish)
#
# both = english.intersection(spanish)
# print(both)
# # print(english & spanish)

# set subset 子集判断
#
# english = set(['door', 'car', 'lunar', 'era'])
# spanish = set(['era', 'lunar', 'hola'])
#
# words = set(['door', 'lunar'])
#
# print('issubset: ', words.issubset(english))
# print('issubset: ', words.issubset(spanish))

# set symmetric difference
# english = set(['door', 'car', 'lunar', 'era'])
# spanish = set(['era', 'lunar', 'hola'])
#
# diff = english.symmetric_difference(spanish)
# print('symmetric_difference: ', diff)

# set union  并集
# english = set(['door', 'car', 'lunar', 'era'])
# spanish = set(['era', 'lunar', 'hola'])
#
# all_the_words = english.union(spanish)
#
# print(english)
# print(spanish)
# print(all_the_words)
#

# set relative complement
# english = set(['door', 'car', 'lunar', 'era'])
# spanish = set(['era', 'lunar', 'hola'])
#
#
# eng = english - spanish  # 这个是求english独有的
# spa = spanish - english
#
# print(spa)
# print(eng)
#
# print(english)
# # print(spanish)
#
# # 这是遍历
# for i in english:
#     print(i)